package com.ruoyi.gams.vo;

import lombok.Data;

import java.io.Serializable;

@Data
public class Result<T> implements Serializable
{

    private static final long serialVersionUID = 1L;

    private int code;
    private String msg;
    private T data;


    /**
     * 成功时候的调用
     */
    public static <T> Result<T> success(T data)
    {
        return new Result<>(data);
    }

    /**
     * 失败时候的调用
     */
    public static <T> Result<T> error(int code, String codeMsg)
    {
        return new Result<>(code, codeMsg);
    }

    public static <T> Result<T> error()
    {
        return new Result<>(-1, "error");
    }

    public static <T> Result<T> success()
    {
        return new Result<>(1, "success");
    }

    public Result(T data)
    {
        this.code = 1;
        this.data = data;
        this.msg = "success";
    }

    private Result(int code, String msg)
    {
        this.code = code;
        this.msg = msg;
    }
}
